import 'package:file_picker/file_picker.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/demo_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:github_client_app/db/sqlite.dart';
import 'package:github_client_app/page/index_page.dart';
import 'package:github_client_app/provider/locale_provider.dart';
import 'package:github_client_app/provider/theme_provider.dart';
import 'package:github_client_app/router/routes.dart';
import 'package:github_client_app/services/http/dio_util.dart';
import 'package:github_client_app/services/tcp/tcp_util.dart';
import 'package:provider/provider.dart';
import 'package:bot_toast/bot_toast.dart';

main(List<String> args) async {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key) {
    Routes.configureRoutes(); // 路由
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter project",
      home: const MyHome(),
    );
  }
}

class MyHome extends StatelessWidget {
  const MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("ddddd")),
      body: Column(
        children: [
          OrientationBuilder(builder: (context, orientation) {
            print("屏幕旋转");
            return Center(
              child: Flex(
                direction: orientation == Orientation.landscape
                    ? Axis.horizontal
                    : Axis.vertical,
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  for (int i = 0; i < 3; i++) FlutterLogo(size: 50),
                ],
              ),
            );
          }),
          ElevatedButton(
              onPressed: () async {
                String? selectedDirectory =
                    await FilePicker.platform.getDirectoryPath();
                // /storage/emulated/0/Alarms
                print('selectedDirectory:$selectedDirectory');
// /Users/jewel/Library/Developer/CoreSimulator/Devices/0CF51572-4B0E-4F61-8ECD-FC83B37E429F/data/Library/Mobile Documents/com~apple~CloudDocs
// /Users/jewel/Library/Developer/CoreSimulator/Devices/0CF51572-4B0E-4F61-8ECD-FC83B37E429F/data/Containers/Data/Application/79E2C4EC-EE0A-4063-B4BB-C0ABA77AF4C0/tmp/com~apple~CloudDocs
              },
              child: Text("选择文件"))
        ],
      ),
    );
  }
}
